#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QLabel>

#include "weatherInfo.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

struct Yesterday {
    QString date = "02" ;
    QString high = "高温 3℃";
    QString low = "低温 -8℃";
    QString ymd = "2023-01-02";
    QString week = "星期一";
    QString sunrise = "07:36";
    QString sunset = "17:00";
    QString fx = "北风";
    QString fl = "2级" ;
    QString type = "多云";
    QString notice = "阴晴之间，谨防紫外线侵扰";
    double aqi = 20 ;
};

struct Forecast {
    QString date = "03";
    QString high = "高温 3℃";
    QString low = "低温 -8℃";
    QString ymd = "2023-01-03";
    QString week = "星期二";
    QString sunrise = "07:36";
    QString sunset = "17:01";
    QString fx = "北风";
    QString fl = "1级";
    QString type = "晴";
    QString notice = "愿你拥有比阳光明媚的心情";
    double aqi = 29;
};

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

protected:

    // 默认的线程在Qt中称之为窗口线程，也叫主线程，负责窗口事件处理或者窗口控件数据的更新
    void mousePressEvent(QMouseEvent* ev) override;
    void mouseMoveEvent(QMouseEvent* ev) override;
    void updateUI();

private slots:
    void on_btnSearch_clicked();
    void parseJson(QByteArray& replyJson);

private:
    Ui::MainWindow* ui;
    QPoint m_distance;
    QNetworkAccessManager* mNetAccessManager;
    Yesterday mYesterday;
    Forecast mForecast[5];
    QMap<QString, QString> mTypeMap;

};
#endif  // MAINWINDOW_H
